package Code;
public class Base {
	
	private Team team;
	private Point[] corners;
	
	public Base(String[] attrs) {
		team = Team.valueOf(attrs[1].toUpperCase());
		
		corners = new Point[4];
		corners[0] = new Point(Double.parseDouble(attrs[2]), Double.parseDouble(attrs[3]));
		corners[1] = new Point(Double.parseDouble(attrs[4]), Double.parseDouble(attrs[5]));
		corners[2] = new Point(Double.parseDouble(attrs[6]), Double.parseDouble(attrs[7]));
		corners[3] = new Point(Double.parseDouble(attrs[8]), Double.parseDouble(attrs[9]));
	}
	
	public Point getCorner(Corner corner) {
		return corners[corner.getPosition()];
	}
	
	public Point getCorner(int corner) {
		if(corner < 0 || corner >= 4) throw new IllegalArgumentException("must be between in [0, 4)");
		return corners[corner];
	}
	
	public Team getTeam() {
		return team;
	}
	
	public Point getCenter() {
		double x = 0;
		double y = 0;
		for(int i = 0; i < corners.length; i++) {
			x += corners[i].getX();
			y += corners[i].getY();
		}
		return new Point(x/corners.length, y/corners.length);
	}
}
